#x,n,bitNum输入变量
if(is.null(n) || n == 0) {
    n <- ceiling(sqrt(length(x)))
}

m <- length(x)
cl <- c(-3, -2, -1, 0, 1, 2, 3)
#group <- matrix(c(x, rep(NA, (n - m %% n) %% n)), ncol=n, byrow=T)
group <- matrix(c(x, rep(NA, (n - m %% n) %% n)), nrow=n, byrow=T)

#平均值
claData <- apply(group, 1, mean, na.rm=T)

#对比线
CL <- mean(claData) + cl * sd(claData)

#精确位数
if (bitNum > 0) {
    claData <- round(claData, bitNum)
    CL <- round(CL, bitNum)
}